module top_module( 
    input [399:0] a, b,
    input cin,
    output cout,
    output [399:0] sum );

    generate
        genvar i;
        for(i=0;i<=99;i=i+1)
        begin:BCD_100
            wire carry;
            if(i==0)
                bcd_fadd add(.a(a[3:0]),.b(b[3:0]),.cin(cin),.cout(carry),.sum(sum[3:0]));
            else
                bcd_fadd add(.a(a[4*i+3:4*i]),.b(b[4*i+3:4*i]),.cin(BCD_100[i-1].carry),.cout(carry),.sum(sum[4*i+3:4*i]));
        end
    endgenerate
    assign cout = BCD_100[99].carry;

endmodule
